import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入自定义深色主题
// import './styles/dark-theme.scss'
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'


// 完整导入 UI 组件库
import VxeUIAll, { VxeUI } from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
Vue.use(VxeUIAll)
// 完整导入 表格库
import VxeUITable from 'vxe-table'
import 'vxe-table/lib/style.css'
Vue.use(VxeUITable)
// elemenu-vxe
import VxeUIPluginRenderElement from '@vxe-ui/plugin-render-element'
import '@vxe-ui/plugin-render-element/dist/style.css'
VxeUI.use(VxeUIPluginRenderElement)

import '@/icons' // icon
import '@/permission' // permission control
import buttonPermission from './directives/button-permission';
// 注册全局指令
Vue.directive('permission', buttonPermission);

// 图片处理
import errorHandlerMixin from './mixins/errorHandlerMixin'
Vue.mixin(errorHandlerMixin);

import i18n from './lang'


let Modules = [
  require.context("./components/table", true, /\.vue$/),
  require.context("./components/input", true, /\.vue$/),
  require.context("./components/select", true, /\.vue$/),
  require.context("./components/dialog", true, /\.vue$/),
  require.context("./components/date", true, /\.vue$/),
  require.context("./components/form", true, /\.vue$/)
];
Modules.forEach(el => {
  el.keys().forEach(fileName => {
    const componentConfig = el(fileName);
    const componentName = fileName.replace(/^\.\//, "").replace(/\.vue$/, "");
    const component = Vue.component(
      componentName.replace(/\//, "-"),
      componentConfig.default || componentConfig
    );
  });
});

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI, { size: 'mini', zIndex: 3000 })


Vue.config.productionTip = false

new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
